import os

def search(path, num, hideable=False, dirable=False):
    lst = os.listdir(path)
    if not hideable:
        for item in lst:
            if item[0] == ".":
                lst.remove(item)
    if dirable:
        num += 1
    for item in lst:
        if os.path.isfile(os.path.join(path, item)):
            num += 1
        if os.path.isdir(os.path.join(path, item)):
            ss = os.path.join(path, item)
            num = search(ss, num, hideable, dirable)
    return num

path = "/home/pi/py_class_1/"
print(path+'有'+str(search(path, 0))+"个文件")
